package com.ling.common.library.utils

/**
 * @author Ling
 * @date :2024/11/26 16:40
 */

object QuickClickUtil {
    private var oldClickTime = 0L
    private var currentTime = 0L

    /**
     * @return boolean值为是否可以执行点击事件逻辑
     */
    fun handleClick(time: Long): Boolean {
        val nowTimes = System.currentTimeMillis()
        if (nowTimes - oldClickTime > time) {
            oldClickTime = nowTimes
            return false
        } else {
            return true
        }
    }

    //设置当前监控时间
    fun setTime(time: Long) {
        currentTime = time
    }

    //是否满足距离上次设置监控时间的最少时间间隔
    fun isOverTime(time: Long): Boolean {
        return System.currentTimeMillis() - time >= currentTime
    }
}